//Master View Component Constructor
function MasterView() {
	//create object instance, parasitic subclass of Observable
	var self = Ti.UI.createView({
		backgroundColor:'white'
	});

	

	//Main Menu Butons call the process class, the process class takes the title as an input parameter
	var data = [
		{title:'Time Management Overview', detail:'pmp', test:'ui/common/process/process',hasChild:true, borderColor: '#333'},
		{title:'Plan Schedule Management', detail:'pmp', test:'ui/common/process/process',hasChild:true, color: '#000'},
		{title:'Define Activities', detail:'pmp', test:'ui/common/process/process', hasChild:true, color: '#000'},
		{title:'Sequence Activities', detail:'pmp',  test:'ui/common/process/process',hasChild:true, color: '#000'},
		{title:'Estimate Activity Resources', detail:'pmp', test:'ui/common/process/process', hasChild:true, color: '#000'},
		{title:'Estimate Activity Duration', detail:'pmp', test:'ui/common/process/process', hasChild:true, color: '#000'},
		{title:'Develop Schedule', detail:'pmp', test:'ui/common/process/process', hasChild:true, color: '#000'},
		{title:'Control Schedule', detail:'pmp', test:'ui/common/process/process', hasChild:true, color: '#000'}
	];

	// create table view
	for (var i = 0; i < data.length; i++ ) {
		var d = data[i];
		// On Android, if touchEnabled is not set explicitly, its value is undefined.
		if (d.touchEnabled !== false) {
			d.color = '#000';
		}
		d.font = {fontWeight:'bold'};
	};
	var tableview = Titanium.UI.createTableView({
		data:data
	});
	
	// create table view event listener
	tableview.addEventListener('click', function(e) {
		if (e.rowData.test) {
			
	   self.fireEvent('processSelected', {
			name:e.rowData.title,
			detail:e.rowData.detail
		});
		}
	});
	
	
	
	// add table view to the window
	
	self.add(tableview);
	
	return self;
};

module.exports = MasterView;